version: '3'

services:
  flask_app1:
    image: flask_app_image
    networks:
      internal_network:
        ipv4_address: 10.20.0.2

  flask_app2:
    image: flask_app_image
    networks:
      internal_network:
        ipv4_address: 10.20.0.3

  flask_load_balancer:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./certs:/etc/nginx/certs:ro
    ports:
      - "5000:443"
    networks:
      internal_network:
        ipv4_address: 10.20.0.4
      external_network:
        ipv4_address: 172.30.0.2
    extra_hosts:
      - "flask:172.20.0.1"

networks:
  internal_network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.20.0.0/16
  external_network:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.30.0.0/16
